// 实现一个从对象中取值的类
class ObjectImpl<T extends object, K extends keyof T> {
  object!: T;
  key!: K;

  constructor(object: T, key: K) {
    this.object = object;
    this.key = key;
  }

  get value() {
    return this.object[this.key];
  }

  set value(value: T[K]) {
    this.object[this.key] = value;
  }
}

function func<T>(value: T): T {
  return value;
}

interface Ref<T> {
  value: T;
}

type commonFunc = (...args: any[]) => any;
interface CommonFuncI {
  (...args: any[]): any;
}

function createFactory(Constructor: { new (...args: any): any }) {
  return new Constructor();
}

const obj = {
  name: '11',
  age: 11,
};
// 可以取一个对象key对象的值类型定义，这里返回string
type nameType = typeof obj['name'];
const o = new ObjectImpl(obj, 'name');
var aa = o.value;
